import Vue from 'vue'
import Vuex from 'vuex'
import {getToken} from "../utils/auth";

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    token: getToken() || '',
    userId: '',
    username: '',
    role: ''
  },
  mutations: {
    SET_USERID: (state, userId) => {
      state.userId = userId;
    },

    SET_USERNAME: (state, username) => {
      state.username = username;
    },

    SET_ROLE: (state, role) => {
      state.role = role;
    }
  },
  actions: {
  },
  modules: {
  }
})

export default store;
